//--------------------------------------------------------------------------------
// This file is a \"Sample\" as from Windows Workflow Foundation
// Samples
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation.  See these other
// materials for detailed information regarding Microsoft code samples.
// 
// THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//--------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;

namespace MNS.Activities
{
    /// <summary>
    /// Defines the designer for the ParallelIf activity
    /// </summary>
    [ActivityDesignerTheme(typeof(IteratorTheme))]
    public class IteratorDesigner : SequentialActivityDesigner //ParallelActivityDesigner
    {
        public override bool CanInsertActivities(HitTestInfo insertLocation, ReadOnlyCollection<Activity> activitiesToInsert)
        {
            return true;
        }

        public override bool CanMoveActivities(HitTestInfo moveLocation, ReadOnlyCollection<Activity> activitiesToMove)
        {
            return true;
        }

        public override bool CanRemoveActivities(ReadOnlyCollection<Activity> activitiesToRemove)
        {
            return true;
        }

        //protected override CompositeActivity OnCreateNewBranch()
        //{
        //    return new ParallelIfBranch();
        //}

        //private void OnAddBranch(object sender, EventArgs e)
        //{
        //    CompositeActivity activity1 = this.OnCreateNewBranch();
        //    CompositeActivity activity2 = base.Activity as CompositeActivity;
        //    if ((activity2 != null) && (activity1 != null))
        //    {
        //        int num1 = this.ContainedDesigners.Count;
        //        Activity[] activityArray1 = new Activity[] { activity1 };
        //        CompositeActivityDesigner.InsertActivities(this, new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count), new List<Activity>(activityArray1).AsReadOnly(), string.Format("Adding branch {0}", activity1.GetType().Name));
        //        if ((this.ContainedDesigners.Count > num1) && (this.ContainedDesigners.Count > 0))
        //        {
        //            this.ContainedDesigners[this.ContainedDesigners.Count - 1].EnsureVisible();
        //        }
        //    }
        //}

        //protected override void OnExecuteDesignerAction(DesignerAction designerAction)
        //{
        //    // OK, this is a bit pants...
        //    if (designerAction.UserData.Contains("LESS_THAN_TWO"))
        //    {
        //        CompositeActivity parent = this.Activity as CompositeActivity;

        //        if (null != parent)
        //        {
        //            while ( parent.Activities.Count < 2 )
        //                OnAddBranch(this, EventArgs.Empty);
        //        }
        //    }
        //    else
        //        base.OnExecuteDesignerAction(designerAction);
        //}
    }
}